package com.leijingqi.mapper;

import com.leijingqi.pojo.Emp;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EmpMapper {
    //根据id删除数据
    @Delete("delete from emp where id = #{id}")
    public int delete(Integer id);
    //新增员工
    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into emp(username, name, gender, image, job, entrydate, dept_id, create_time, update_time)" +
            " values (#{username},#{name},#{gender},#{image},#{job},#{entrydate},#{deptId},#{createTime},#{updateTime})")
    public void insert(Emp emp);

    //个更新员工 (修改)
    @Update("update emp set username = #{username} ,name = #{name} ,gender= #{gender},image= #{image}," +
            "job= #{job},entrydate= #{entrydate},dept_id= #{deptId},update_time= #{updateTime} where id =  #{id} ")
    public  void updata(Emp emp);
    public  void updata2(Emp emp);

    //根据id查询信息
    @Select("Select * from emp where id = #{id}")
    public Emp getById(Integer id);

    //条件查询
//    @Select("select * from emp where name like '%${name}%' and gender = #{gender} " +
//            "and entrydate between #{begin} and #{end} order by update_time desc")
//        @Select("SELECT * from emp WHERE name like concat('%',#{name},'%')  AND gender = 1 AND entrydate BETWEEN '2010-01-01' and '2020-01-01' ORDER BY update_time DESC")
    public List<Emp> whereSelect(String name, Short gender , LocalDate begin ,LocalDate end  );

    //批量删除员工
    public  void deleteByIds(List<Integer> ids);
}
